import * as R from "ramda";
function pipe() {
  return async function (ctx: Record<string, any>, next: Function) {
    // 当 Content-Type 为 fromdata 时，打包数据
    if (ctx.payload && ctx.axios.headers['Content-Type'] === 'application/x-www-form-urlencoded' && ctx.axios.method.toUpperCase() == 'POST') {
      let formdata = new FormData();
      for (var key in ctx.payload) {
        console.log(key, ctx.payload[key], 'key')
        formdata.append(key, ctx.payload[key])
      }
      ctx.payload = formdata;
    }
    await next()
  }
}
export default pipe;